import 'package:boss/models/packing_data.dart';
import 'package:boss/ui/page/takeoutManagement/page/packagingFeeSetting/provider/package_provider.dart';
import 'package:boss/ui/widget/button/fixed_bottom_btn.dart';
import 'package:boss/ui/widget/loader/loader.dart';
import 'package:hi_common/hi_common.dart';
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';

import 'packaging_rule_panel.dart';
import 'packaging_without_commodity_panel.dart';

class PackagingFeeBrowser extends StatefulWidget {
  @override
  _PackagingFeeBrowserState createState() => _PackagingFeeBrowserState();
}

class _PackagingFeeBrowserState extends State<PackagingFeeBrowser> {
  @override
  Widget build(BuildContext context) {
    final provider = Provider.of<PackageProvider>(
      context,
      listen: false,
    );
    return Loader<PackingData>(
      loadTask: provider.initData,
      builder: (context) => Column(
        children: <Widget>[
          Expanded(
            child: SingleChildScrollView(
              padding: EdgeInsets.symmetric(
                vertical: 30.w
              ),
              child: Column(
                crossAxisAlignment: CrossAxisAlignment.start,
                children: <Widget>[
                  PackagingRulePanel(),
                  PackagingWithoutCommodityPanel(),
                ],
              ),
            ),
          ),
          FixedBottomBtn(
            title: '保存',
            onTap: () {
              provider.update();
            },
          ),
        ],
      ),
    );
  }
}
